﻿using Rhino.Etl.Core;
using Rhino.Etl.Core.Operations;

namespace Sqloogle.Operations {

    public class CachedSqlAggregate : AbstractAggregationOperation   {

        protected override void Accumulate(Row row, Row aggregate)
        {
            aggregate["sqlscript"] = row["sqlscript"];
            aggregate["type"] = row["type"];

            if (aggregate["use"] == null) {
                aggregate["use"] = 0;
            }

            aggregate["use"] = ((int) aggregate["use"]) + ((int) row["use"]);
        }

        protected override string[] GetColumnsToGroupBy() {
            return new string[] { "sqlscript", "type"};
        }
    }
}
